package com.mewpipe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mewpipe.dao.DaoFactory;
import com.mewpipe.dao.UserDao;
import com.mewpipe.entity.User;
import com.mewpipe.entity.UserSession;


@SuppressWarnings("serial")
@WebServlet ("/GetUserInfo")
public class GetUserInfoServlet extends HttpServlet{

	private UserDao userDao;
	
	@Override
	public void init() throws ServletException {
		userDao = DaoFactory.getInstance().getUserDao();
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		User user_info ;
		
		
		// long id = Long.parseLong(req.getParameter("id"));
		HttpSession session= req.getSession();
		UserSession usersession = (UserSession) session.getAttribute("UserSession");
		long id = usersession.getId();
		
		user_info = userDao.getUserInfo(id);
		req.setAttribute("User_Info",user_info);
		req.getRequestDispatcher("/profil.jsp").forward(req, resp);
		
		
	}
	

}
